﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;


namespace PuzzleCoop
{
    public class Enemy : Character
    {
        Vector2 dir = Vector2.Zero;

        public Enemy(PlayScreen playScreen, Vector2 pos)
            : base(playScreen, GameScreenManager.Load<Texture2D>("Images\\Characters\\ciclope"))
        {
            position = pos;
            velocity = 2;
        } 

        public override void Update(GameTime gameTime)
        {
            if (Rand.Next(50) == 0) ChangeDirecton();
            //while (CheckCollisionWithBoard()) ChangeDirecton();
            Move(dir);

            base.Update(gameTime);
        }

        public override void Draw(SpriteBatch spriteBatch)
        {
            base.Draw(spriteBatch);
        }

        public void ChangeDirecton()
        {
            dir = Vector2.Zero;
            if (Rand.NextBool()) dir += Direction.Up;
            if (Rand.NextBool()) dir += Direction.Left;
            if (Rand.NextBool()) dir += Direction.Right;
            if (Rand.NextBool()) dir += Direction.Down;
            if (dir != Vector2.Zero)
                dir.Normalize();
        }
    }
}
